================================================================================
WHATSAPP SELF-HOSTED GATEWAY - QUICK REFERENCE CARD
================================================================================

Simpan file ini untuk referensi cepat!

================================================================================
📍 URLS
================================================================================

Admin Panel:
http://localhost/mikhmon/settings/whatsapp_gateway_admin.php

Health Check:
http://localhost:3000/health

Status API:
http://localhost:3000/api/status

QR Code API:
http://localhost:3000/api/qr

================================================================================
⚡ COMMANDS
================================================================================

# Start Gateway (Development)
cd whatsapp-gateway
npm start

# Start Gateway (Production)
npm run pm2

# Check Status
pm2 status

# View Logs
pm2 logs mikhmon-wa-gateway

# Restart
pm2 restart mikhmon-wa-gateway

# Stop
pm2 stop mikhmon-wa-gateway

# Auto-start on Boot
pm2 startup
pm2 save

# Health Check
curl http://localhost:3000/health

================================================================================
🔧 TROUBLESHOOTING
================================================================================

QR Code tidak muncul:
pm2 restart mikhmon-wa-gateway

Pesan tidak terkirim:
curl http://localhost:3000/api/status

Gateway crash:
pm2 logs mikhmon-wa-gateway
pm2 restart mikhmon-wa-gateway

Port sudah dipakai:
Edit .env: PORT=3001
Edit whatsapp_config.php: URL port 3001

Connection putus:
Scan QR code ulang di admin panel

================================================================================
📁 FILE LOCATIONS
================================================================================

Gateway Service:
whatsapp-gateway/

Configuration:
whatsapp-gateway/.env
include/whatsapp_config.php

Session Data:
whatsapp-gateway/auth_info/

Logs:
pm2 logs mikhmon-wa-gateway
mikhmon/logs/whatsapp_log.txt
wa_message_logs table

Admin Panel:
settings/whatsapp_gateway_admin.php

Documentation:
WHATSAPP_GATEWAY_INSTALLED.txt
WHATSAPP_SELFHOSTED_QUICKSTART.md
WHATSAPP_SELFHOSTED_GUIDE.md

================================================================================
🔌 API ENDPOINTS
================================================================================

Base URL: http://localhost:3000
Auth: Header X-API-Key: your-api-key

GET  /health              Health check
GET  /api/status          Connection status
GET  /api/qr              Get QR code
POST /api/send            Send message
POST /api/send-bulk       Send bulk
POST /api/logout          Logout
POST /api/restart         Restart
GET  /api/logs            Get logs

================================================================================
📊 MONITORING
================================================================================

Connection Status:
Admin Panel → Status badge

Gateway Logs:
pm2 logs mikhmon-wa-gateway

Message Logs:
tail -f mikhmon/logs/whatsapp_log.txt

Database Logs:
SELECT * FROM wa_message_logs ORDER BY id DESC LIMIT 50;

Health Check:
curl http://localhost:3000/health

================================================================================
🔐 SECURITY
================================================================================

API Key Location:
whatsapp-gateway/.env
include/whatsapp_config.php

MUST BE SAME!

Session Data:
whatsapp-gateway/auth_info/
BACKUP THIS FOLDER!

Firewall:
Port 3000 (internal only)

HTTPS:
Use reverse proxy (Nginx/Apache)

================================================================================
💾 BACKUP
================================================================================

Session Data:
cp -r whatsapp-gateway/auth_info/ backup/

Configuration:
cp whatsapp-gateway/.env backup/
cp include/whatsapp_config.php backup/

Database:
mysqldump mikhmon_agents wa_message_logs > backup.sql

================================================================================
🎯 USAGE
================================================================================

Send Voucher:
1. Hotspot → Generate Users
2. Centang "Kirim ke WhatsApp"
3. Input nomor customer
4. Generate!

Test Message:
1. Admin Panel
2. Test Message section
3. Input nomor & pesan
4. Send!

Bot Commands:
Customer: "HARGA" → Daftar paket
Customer: "BELI 1JAM" → Generate voucher
Customer: "HELP" → Bantuan

================================================================================
📞 SUPPORT
================================================================================

Documentation:
WHATSAPP_GATEWAY_INSTALLED.txt
WHATSAPP_SELFHOSTED_QUICKSTART.md
WHATSAPP_SELFHOSTED_GUIDE.md
WHATSAPP_GATEWAY_INDEX.md

Checklist:
WHATSAPP_GATEWAY_CHECKLIST.txt

Architecture:
WHATSAPP_GATEWAY_ARCHITECTURE.txt

================================================================================
🚨 EMERGENCY
================================================================================

Gateway tidak start:
cd whatsapp-gateway
npm install
npm start

Session hilang:
Restore dari backup atau scan QR ulang

Database error:
Check MySQL running
Check credentials di .env

Connection error:
Check internet
Restart gateway
Scan QR code ulang

================================================================================
✅ CHECKLIST
================================================================================

[ ] Node.js installed
[ ] Dependencies installed
[ ] API key configured
[ ] Gateway running
[ ] QR code scanned
[ ] Status: Connected
[ ] Test message sent
[ ] PM2 configured
[ ] Auto-start enabled
[ ] Backup done

================================================================================
📈 PERFORMANCE
================================================================================

Messages/minute: ~30 (with 2s delay)
RAM usage: 100-500MB
CPU usage: 5-30%
Startup time: 10-30 seconds
Reconnect time: 5-10 seconds

================================================================================
🔄 MAINTENANCE
================================================================================

Weekly:
- Check status: pm2 status
- Check logs: pm2 logs
- Backup session: auth_info/

Monthly:
- Backup database
- Update dependencies: npm update
- Restart gateway: pm2 restart
- Clean old logs: pm2 flush

================================================================================

Version: 1.0.0
License: GPL-2.0
Author: MikhMon Team

🚀 HAPPY MESSAGING! 🚀

================================================================================
